package service 
{
	import cn.inswf.framework.mvcs.Actor;
	import data.LMS;
	import event.AiccEvent;
	import flash.display.DisplayObjectContainer;
	import flash.external.ExternalInterface;
	import util.JsUtil;
	
	/**
	 * ...
	 * @author liwei
	 */
	public class JsService extends Actor 
	{
		[Inject]
		public var _container:DisplayObjectContainer;
		public function JsService() 
		{
			super();
		}
		override public function onRegister():void 
		{
			if (ExternalInterface.available) {
				ExternalInterface.addCallback("jsCall", jsCall);
			}
		}
		public function getInitData():void {
			JsUtil.call("getInitData()");
		}
		private function jsCall(name:String, value:String):void {
			
			if (name == "scormData") {
				//scorm数据调定
				if (LMS.decodeScorm(value)) {
					dispatchEvent(new AiccEvent(AiccEvent.READ_COMPLETE));
				}
			}else if (name == "aiccData") {
				//aicc数据调定
			}else if (name == "mastery_score") {
				if (value != "") {
					JsUtil.call("alert('"+value+"')");
				}
			}
		}
	}

}